<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:param name="studentNr"/>
<xsl:template match="/StudentenAdministratie/Studenten/Student[@StudentNr=$studentNr]">
	<fo:root>
		<fo:layout-master-set>
		  <fo:simple-page-master master-name="A4"
							    page-height="297mm"
						        page-width="210mm"
						        margin-top="2cm"
						        margin-bottom="2cm"
						        margin-left="1cm"
						        margin-right="1cm">			
			<fo:region-body margin-top="2.5cm" margin-bottom="2cm"/>
			<fo:region-before extent="1cm"/>
		  </fo:simple-page-master>
		</fo:layout-master-set>
		
		<fo:page-sequence master-reference="A4">
		<xsl:call-template name="headerall"/>
		  <fo:flow flow-name="xsl-region-body">
		    <fo:block>
		      <fo:table border-collapse="collapse" border-color="black" left="0cm" right="21cm" table-layout="fixed" width="100%">
				<fo:table-column column-width="50%"/>
				<fo:table-column column-width="50%"/>
				<fo:table-header background-color="#0f5094" start-indent="0pt">
				  <fo:table-row border-collapse="collapse" text-align="center" display-align="center" font-weight="bold" color="white">
				    <fo:table-cell  padding="2pt">
				      <fo:block>Cursus</fo:block>
				    </fo:table-cell>
				    <fo:table-cell padding="2pt">
				      <fo:block>Resultaat</fo:block>
				    </fo:table-cell>
				  </fo:table-row>
				</fo:table-header>
				<fo:table-body>
				<xsl:for-each select="Cijfers/Cijfer">
   				    <fo:table-row border-collapse="collapse" text-align="center" font-weight="bold">
					  <fo:table-cell  padding="2px" color="#0f5094">
							<fo:block><xsl:value-of select="@CursusAfkorting"/></fo:block>
					  </fo:table-cell>
					  <fo:table-cell  padding="2px">
							<xsl:if test="@Resultaat &lt;= 5">
								<fo:block color="red"><xsl:value-of select="@Resultaat"/></fo:block>
							</xsl:if>
							<xsl:if test="@Resultaat &gt; 5">
								<fo:block  color="#0f5094" ><xsl:value-of select="@Resultaat"/></fo:block>
							</xsl:if>
					  </fo:table-cell>
				  </fo:table-row>
				  </xsl:for-each>
   				</fo:table-body>
   			  </fo:table>
		    </fo:block>
		    <fo:block id="last-page"/>
		  </fo:flow>
		</fo:page-sequence>
	</fo:root>
</xsl:template>
<xsl:template name="headerall">
	<fo:static-content flow-name="xsl-region-before">
		<fo:block>
			<fo:table table-layout="fixed" width="100%" border-spacing="2pt">
				<fo:table-column column-width="75%"/>
				<fo:table-column column-width="25%"/>
				<fo:table-body>
					<fo:table-row>
						<fo:table-cell number-columns-spanned="2" padding="0" height="30">
							<fo:block>
								<fo:external-graphic src="src/xmlopdracht2/resources/171.GIF">
								</fo:external-graphic> 
							</fo:block>
						</fo:table-cell>
					</fo:table-row>
					<fo:table-row>
						<fo:table-cell font-size="10pt" padding="0" text-align="left" display-align="center">
							<fo:block font-weight="bold">Voortgangsrapportage: 
								<xsl:value-of select="Voornaam"/><xsl:text> </xsl:text>
								<xsl:value-of select="Tussenvoegsel"/><xsl:text> </xsl:text>
								<xsl:value-of select="Achternaam"/><xsl:text> </xsl:text>
								(<xsl:value-of select="@StudentNr"/>)
							</fo:block>
						</fo:table-cell>
						<fo:table-cell  font-size="10pt" padding="0" text-align="right" display-align="center" font-weight="bold">
							<fo:block>Page: <fo:page-number/>/<fo:page-number-citation ref-id="last-page"/></fo:block>
						</fo:table-cell>
					</fo:table-row>
					<fo:table-row>
						<fo:table-cell number-columns-spanned="2" padding="0" display-align="center">
							<fo:block>
								<fo:block text-align="center">
									<fo:leader leader-pattern="rule" rule-thickness="1" leader-length="100%" color="black"/>
								</fo:block>
							</fo:block>
						</fo:table-cell>
					</fo:table-row>
				</fo:table-body>
				</fo:table>
		</fo:block>
	</fo:static-content>
</xsl:template>
</xsl:stylesheet>
